package models

import "time"

type ContentModel struct {
	Id           int64
	Title        string
	Url          string
	ContentHash  string
	Price        float64
	IdentityCard string
	CreatedAt    time.Time `xorm:"created"`
}

func NewContentModel() *ContentModel {
	return new(ContentModel)
}

func (m *ContentModel) Add(model ContentModel) (err error) {
	_, err = localdb.Table("content").Insert(&model)
	return
}

func (m *ContentModel) List(identityCard string) (list []ContentModel, err error) {
	err = localdb.Table("content").Where("identity_card = ?", identityCard).Find(&list)
	return
}

// GetAllList 查询全部作品
func (m *ContentModel) GetAllList() (list []ContentModel, err error) {
	err = localdb.Table("content").Find(&list)
	return
}
